package com.yang.security.user;

import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

/**
 * Created by baipan
 * Date: 2019-12-18
 * 自定义SpringSecurity UsernamePassword 类
 * 此处依然使用SpringSecurity提供，实际上就按需要重写
 */
public class CustomUsernamePasswordAuthenticationToken extends UsernamePasswordAuthenticationToken {

    public CustomUsernamePasswordAuthenticationToken(Object principal,
                                                     Object credentials) {
        super(principal, credentials);
    }


    public CustomUsernamePasswordAuthenticationToken(Object principal,
                                                     Object credentials,
                                                     Collection<? extends GrantedAuthority> authorities) {
        super(principal, credentials, authorities);
    }


    public static CustomUsernamePasswordAuthenticationToken build(Object principal, Object credentials) {
        return new CustomUsernamePasswordAuthenticationToken(principal, credentials);
    }


    public static CustomUsernamePasswordAuthenticationToken build(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) {
        return new CustomUsernamePasswordAuthenticationToken(principal, credentials, authorities);
    }
}
